package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ParkingInfo;
import com.ruoyi.service.IParkingInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 停车场信息Controller
 * 
 * @author dongdong
 * @date 2025-08-26
 */
@RestController
@RequestMapping("/parking/parkingInfo")
public class ParkingInfoController extends BaseController
{
    @Autowired
    private IParkingInfoService parkingInfoService;

    /**
     * 查询停车场信息列表
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ParkingInfo parkingInfo)
    {
        startPage();
        List<ParkingInfo> list = parkingInfoService.selectParkingInfoList(parkingInfo);
        return getDataTable(list);
    }

    /**
     * 导出停车场信息列表
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingInfo:export')")
    @Log(title = "停车场信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkingInfo parkingInfo)
    {
        List<ParkingInfo> list = parkingInfoService.selectParkingInfoList(parkingInfo);
        ExcelUtil<ParkingInfo> util = new ExcelUtil<ParkingInfo>(ParkingInfo.class);
        util.exportExcel(response, list, "停车场信息数据");
    }

    /**
     * 获取停车场信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(parkingInfoService.selectParkingInfoById(id));
    }

    /**
     * 新增停车场信息
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingInfo:add')")
    @Log(title = "停车场信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkingInfo parkingInfo)
    {
        return toAjax(parkingInfoService.insertParkingInfo(parkingInfo));
    }

    /**
     * 修改停车场信息
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingInfo:edit')")
    @Log(title = "停车场信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkingInfo parkingInfo)
    {
        return toAjax(parkingInfoService.updateParkingInfo(parkingInfo));
    }

    /**
     * 删除停车场信息
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingInfo:remove')")
    @Log(title = "停车场信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(parkingInfoService.deleteParkingInfoByIds(ids));
    }

    @GetMapping("/selectList")
    public AjaxResult selectList() {
        return success(parkingInfoService.selectList());
    }
}
